<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <button id="btn">点击发送请求</button>
    <div id="container"></div>
    <script>
        var btn = document.getElementById('btn');
        var container = document.getElementById('container');
        btn.onclick = function() {
            var xhr = new XMLHttpRequest();
            xhr.open('get', '/xml');
            xhr.send();
            xhr.onload = function() {
                // console.log(this.responseXML);
                var result = this.responseXML.getElementsByTagName('title')[0].innerHTML;
                container.innerHTML = result;
            };
        };
    </script>
</body>

</html>